<?php
/*
 * mk script file created on 9-mag-2005
 * jaco_at_pixeldump_dot_org
 * images with alpha channel
 */

include("sample_utils.php");                    // provides some utils and using mk

$swfFN = "sample03.swf";                        // swf to read
$mkim = new MKSwfItemGrabber($swfFN, "", 1, IMAGE_ITEM); // grab image items

$bmList = $mkim->get_itemList();                // get items (images) list

// html publishing
$tbl = new MKTable();                           // new table object
$tRow = array();                                // an array

foreach($bmList as $bm){						// iterate over images list
	$bm->save_image();                          // save image
	$tRow[0] = array();                         // each item of this array correspond to a cell
	$ifn = $bm->get_imageFileName();			// get image file name

	$str = "<img src=\"" .$imgDir;              // wrap into an img html tag
	$str .= $ifn ."\" /><br />";                // build image path
	$str .= $ifn;                               // ...
	$tRow[0]["cellContent"] = $str;             // fill cell
	$tbl->add_row($tRow);                       // add row to table

	if($bm->hasAlpha()){                        // if image contain alpha data
		$tRow[0] = array();                     // ... create new row
		$bm->save_alpha();                      // save alpha data
		$aifn = $bm->get_alphaImageFileName();  // get assigned file name to alpha data

		$str = "<img src=\"" .$imgDir;          // wraps into an img html tag
		$str .= $aifn ."\" /><br />";           // ...
		$str .= "alpha channel: " .$aifn;       // ...
		$tRow[0]["cellContent"] = $str;         // fill cell
		$tbl->add_row($tRow);                   // add row to table
	}
}

// publish data in a table html tag + comment
$str = trace_var($tbl->fetch_html(), "<strong>images saved in: " .SERVER_MKTMP ."</strong>", false, false, true);
echo show_content($str, basename(__FILE__));
?>
